/**
 *
 *      ___                       ___
 *     /\  \          ___        /\  \
 *    /::\  \        /\  \      /::\  \
 *   /:/\:\  \       \:\  \    /:/\ \  \
 *  /:/  \:\  \      /::\__\  _\:\~\ \  \
 * /:/__/ \:\__\  __/:/\/__/ /\ \:\ \ \__\
 * \:\  \  \/__/ /\/:/  /    \:\ \:\ \/__/
 *  \:\  \       \::/__/      \:\ \:\__\
 *   \:\  \       \:\__\       \:\/:/  /
 *    \:\__\       \/__/        \::/  /
 *     \/__/                     \/__/
 *
 * CIS - Clang Indexing Service is a Project Manager & Source code indexing service
 * created so as to simplify the indexing of C/C++ based source code which use
 * standardized build mechanisms.
 *
 **/

#ifndef JSONREQUESTPROCESSOR_H
#define	JSONREQUESTPROCESSOR_H

#include "request.hxx"

#include <string>
#include <vector>

#include <Poco/JSON/Array.h>
#include <Poco/DynamicFactory.h>

namespace cis {

class RequestProcessor {
public:
    RequestProcessor();

    std::string execute(const std::string&);

    ~RequestProcessor();
    
    template <typename T>
    static bool addCommand(const std::string& name) {
        commandFactory.registerClass<T>(name);
        return true;
    }
private:
    std::string extractParams(Poco::JSON::Array::Ptr params);

    RequestProcessor(const RequestProcessor&) {
    }
    
    static Poco::DynamicFactory<Request> commandFactory;
};

}

#endif	/* JSONREQUESTPROCESSOR_H */

